package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
	"time"
)

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		fmt.Println(strings.Repeat("-", 30))
		// 请求头
		fmt.Println(r.Method)
		fmt.Println(r.URL)
		fmt.Println(r.Proto)

		header := r.Header
		fmt.Println(header.Get("user-agent"))
		fmt.Println(header.Get("host"))

		// 请求体
		io.Copy(os.Stdout, r.Body)
		fmt.Println()
		w.Write([]byte(time.Now().Format("2006-01-02 15:04:05")))
	})

	// http.Handle("/www/", http.FileServer(http.Dir("./")))

	http.ListenAndServe("127.0.0.1:9999", nil)
}
